﻿using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using HZ.Supervise.Model.Enum;

public partial class TotalDrugs_UnTradeProcureCatalog : BasePage
{
    public TotalDrugs_UnTradeProcureCatalog()
    {
        this.ModuleNo = Module.药品统计分析.ToString();
        this.PageOperateType = OperateType.零采购药品统计.ToString();
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            BindData();
        }
    }

    private void BindData()
    {
        int TotalRecord=0;

        HZ.Supervise.IBLL.IBLL_ProcureCatalog ip = HZ.Supervise.BLLFactory.IBLL_ProcureCatalog();

        HZ.Supervise.Model.Query.ProcureCatalog pc = new HZ.Supervise.Model.Query.ProcureCatalog();
        pc.ProductName = HZ.Fun.CheckString(txtProductName.Text.Trim());
        pc.MedicineModelName = HZ.Fun.CheckString(txtMedicineModel.Text.Trim());
        pc.Outlookc = HZ.Fun.CheckString(txtOutlookc.Text.Trim());
        pc.IsUsing =true;     //updated by lhl 2010-02-08     药品需是启用状态
        if (!string.IsNullOrEmpty(ddlSortSource.SelectedItem.Value))
        {
            pc.SortSource = int.Parse(ddlSortSource.SelectedItem.Value);   
        }
        pc.CompanyName_SC = HZ.Fun.CheckString(txtCompanyName_SC.Text.Trim());
        pc.CompanyName_TB = HZ.Fun.CheckString(txtCompanyName_ZB.Text.Trim());
        pc.SortFields = " ProductName ASC ";

        IList<HZ.Supervise.Model.View.ProcureCatalog> list　 =  ip.GetUnTradeProcureCatalog(pc, AspNetPager1.CurrentPageIndex, AspNetPager1.PageSize, out TotalRecord);
        AspNetPager1.RecordCount = TotalRecord;
        gvwInfo.DataSource =list;
        gvwInfo.DataBind();

    }


    protected void btnQuery_Click(object sender, EventArgs e)
    {
        AspNetPager1.CurrentPageIndex = 1;
        BindData();
    }
    protected void AspNetPager1_OnPageChanged(object sender, EventArgs e)
    {
        BindData();
    }
    protected void btnExcel_Click(object sender, EventArgs e)
    {
        int TotalRecord = 0;

        HZ.Supervise.IBLL.IBLL_ProcureCatalog ip = HZ.Supervise.BLLFactory.IBLL_ProcureCatalog();

        HZ.Supervise.Model.Query.ProcureCatalog pc = new HZ.Supervise.Model.Query.ProcureCatalog();
        pc.ProductName = HZ.Fun.CheckString(txtProductName.Text.Trim());
        pc.MedicineModelName = HZ.Fun.CheckString(txtMedicineModel.Text.Trim());
        pc.Outlookc = HZ.Fun.CheckString(txtOutlookc.Text.Trim());

        pc.CompanyName_SC = HZ.Fun.CheckString(txtCompanyName_SC.Text.Trim());
        pc.CompanyName_TB = HZ.Fun.CheckString(txtCompanyName_ZB.Text.Trim());
        pc.SortFields = "GoodsID ASC ";

        IList<HZ.Supervise.Model.View.ProcureCatalog> list = ip.GetUnTradeProcureCatalog(pc, 0,0, out TotalRecord);

        System.Data.DataTable dt = HZ.Data.ModelConvert.GetDataTableFromModel<HZ.Supervise.Model.View.ProcureCatalog>(list);

        ExportFile.Instance.ExportData(dt, gvwInfo, this.Page); 
    }
}
